public class Demo2 {

    public static void main(String[] args) throws InterruptedException {
        int count = 0;
        while (count < 10) {
            Thread t1 = new Thread(() -> {
                System.out.println("a");
            });

            Thread t2 = new Thread(() -> {
                try {
                    t1.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("b");

            });

            Thread t3 = new Thread(() -> {
                try {
                    t2.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("c");

            });

            t1.start();
            t2.start();
            t3.start();
            t3.join();
            count++;
        }
    }
}
